package servlet.cuota;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import condominio.excepcion.DAOExcepcion;
import condominio.modelo.Usuario;
import condominio.negocio.GestionCuotas;

@WebServlet("/CuotaEliminarServlet1")
public class CuotaEliminarServlet1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
    public CuotaEliminarServlet1() {
        super();
  
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		HttpSession session = request.getSession();
		Usuario vo = (Usuario)session.getAttribute("USUARIO_ACTUAL");
		
		if (vo ==null){
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
			return;
		}
		
		
		
		
		
		Integer idCuota = Integer.parseInt(request.getParameter("idCuota"));

		GestionCuotas negocio = new GestionCuotas();
		try {
			negocio.eliminar(idCuota);
			//response.sendRedirect(request.getContextPath()
			//		+ "/RolBuscarServlet");
			RequestDispatcher rd = request.getRequestDispatcher("ColocacionCuotas.jsp");
			rd.forward(request, response);
		} catch (DAOExcepcion e) {
			System.out.println(e.getMessage());
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
		}
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

}
